package com.artron.mediaartron.ui.fragment;

import android.os.Bundle;
import android.os.Handler;

import com.artron.baselib.base.BaseStaticFragment;
import com.artron.mediaartron.R;
import com.artron.mediaartron.ui.activity.MainActivity;
import com.artron.mediaartron.ui.activity.StartActivity;
import com.artron.mediaartron.util.SharePreferenceUtils;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-12-06.
 */
public class StartOneFragment extends BaseStaticFragment{

    public static final String IS_FIRST_START = "IsFirstStart";

    public static StartOneFragment newInstance() {
        Bundle args = new Bundle();
        StartOneFragment fragment = new StartOneFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_start_one;
    }

    @Override
    protected void initView() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                boolean isFirstStart = SharePreferenceUtils.getInstance().getBoolean(IS_FIRST_START, true);
                if (isFirstStart) {
                    StartActivity.start(mContext, StartActivity.START_TWO);
                    SharePreferenceUtils.getInstance().putBoolean(IS_FIRST_START, false);
                } else {
                    MainActivity.start(mContext);
                }
                getActivity().finish();
            }
        }, 1500);
    }
}
